function thatDae(str) {
  let reslut = dayjs(str, "MMDD").valueOf();
  let thatdate = dayjs(reslut).format("MM-DD");
  return thatdate;
}
//线路平均运距
$.ajax({
  type: "get",
  async: true, //异步执行
  url: base_url + "/totalAvgline",
  dataType: "json", //返回数据形式为json
  success: function (data) {
    if (data.code == 1000) {
      if (Object.keys(data.data).length !== 0) {
        totalAvglineData = data.data.datas;
        $(".transportDistance_val").text(data.data.land);
        if (totalAvglineData.length !== 0) {
          dataListlineID = totalAvglineData.map((v) => v.lineID);
          dataListavgline = totalAvglineData.map((v) => v.avgline);
          transportDistanceEchart();
        } else {
          $(".transportDistanceEchart").html(
            "<div class='noData'>今日暂无数据</div>"
          );
        }
      }
    } else {
      alert(data.message);
    }
    fn();
  },
  error: function (errorMsg) {
    console.log("请求数据失败");
  },
});
// 平均票价
$.ajax({
  type: "get",
  async: true, //异步执行
  url: base_url + "/avgPrice",
  dataType: "json", //返回数据形式为json
  success: function (data) {
    if (data.code == 1000) {
      if (data.data !== null) {
        ticketPriceData = data.data.datas;
        if (Object.keys(data.data).length !== 0) {
          $(".ticketPrice_avg").text(data.data.avg.toFixed(2));
          if (ticketPriceData.length !== 0) {
            ticketPriceStmtDay = ticketPriceData.map((v) => thatDae(v.stmtDay));
            ticketPriceAvgPrice = ticketPriceData.map((v) => v.avgPrice);
            ticketPriceEchart();
          } else {
            $(".ticketPriceEchart").html(
              "<div class='noData'>今日暂无数据</div>"
            );
          }
        } else {
          $(".ticketPriceEchart").html(
            "<div class='noData'>今日暂无数据</div>"
          );
        }
      } else {
        $(".ticketPriceEchart").html("<div class='noData'>今日暂无数据</div>");
      }
    } else {
      alert(data.message);
    }
    fn();
  },
  error: function (errorMsg) {
    console.log("请求数据失败");
  },
});
// 全员生产率;
$.ajax({
  type: "get",
  async: true, //异步执行
  url: base_url + "/product",
  dataType: "json", //返回数据形式为json
  success: function (data) {
    if (data.code == 1000) {
      if (data.data !== null) {
        productivityData = data.data.datas;
        if (Object.keys(data.data).length !== 0) {
          $(".productivity_avg").text(data.data.avg.toFixed(2) + "%");
          if (productivityData.length !== 0) {
            productivityStmtDay = productivityData.map((v) =>
              thatDae(v.stmtDay)
            );
            productivityPercent = productivityData.map((v) => v.percent);
            productivityEchart();
          } else {
            $(".productivityEchart").html(
              "<div class='noData'>今日暂无数据</div>"
            );
          }
        } else {
          $(".productivityEchart").html(
            "<div class='noData'>今日暂无数据</div>"
          );
        }
      } else {
        $(".productivityEchart").html("<div class='noData'>今日暂无数据</div>");
      }
    } else {
      alert(data.message);
    }
    fn();
  },
  error: function (errorMsg) {
    console.log("请求数据失败");
  },
});

// 线路客运量;
$.ajax({
  type: "get",
  async: true, //异步执行
  url: base_url + "/lnHistPasgrNrAndLnDlyPasgrNr",
  dataType: "json", //返回数据形式为json
  success: function (data) {
    if (data.code == 1000) {
      if (data.data !== null) {
        linePassengerVData = data.data.dataList;
        if (Object.keys(data.data).length !== 0) {
          $(".passengerVolume_max").text(data.data.max);
          if (linePassengerVData.length !== 0) {
            linePassengerVlnDlyPasgrNr = linePassengerVData.map(
              (v) => v.lnDlyPasgrNr
            );
            linePassengerVlnNm = linePassengerVData.map((v) => v.lnNm);
            linePassengerVlnHistPasgrNr = linePassengerVData.map(
              (v) => v.lnHistPasgrNr
            );
            passengerVolumeEchart();
          } else {
            $(".passengerVolumeEchart").html(
              "<div class='noData'>今日暂无数据</div>"
            );
          }
        } else {
          $(".passengerVolumeEchart").html(
            "<div class='noData'>今日暂无数据</div>"
          );
        }
      } else {
        $(".passengerVolumeEchart").html(
          "<div class='noData'>今日暂无数据</div>"
        );
      }
    } else {
      alert(data.message);
    }
    fn();
  },
  error: function (errorMsg) {
    console.log("请求数据失败");
  },
});
// 高峰小时最小发车间隔
$.ajax({
  type: "get",
  async: true, //异步执行
  url: base_url + "/minDptrIntvl",
  dataType: "json", //返回数据形式为json
  success: function (data) {
    if (data.code == 1000) {
      if (data.data !== null) {
        DptrIntvlData = data.data.datas;
        if (Object.keys(data.data).length !== 0) {
          $(".departureInterval_max").text(data.data.max);
          if (DptrIntvlData.length !== 0) {
            lnNm = DptrIntvlData.map((v) => v.lnNm);
            lnHrMinDptrIntvl = DptrIntvlData.map((v) => v.lnHrMinDptrIntvl);
            departureIntervalEchart();
          } else {
            $("#departureIntervalEchart").html(
              "<div class='noData'>今日暂无数据</div>"
            );
          }
        } else {
          $("#departureIntervalEchart").html(
            "<div class='noData'>今日暂无数据</div>"
          );
        }
      } else {
        $("#departureIntervalEchart").html(
          "<div class='noData'>今日暂无数据</div>"
        );
      }
    } else {
      alert(data.message);
    }
    fn();
  },
  error: function (errorMsg) {
    console.log("请求数据失败");
  },
});
//客运强度
passengerTransportEchart();
function passengerTransportEchart() {
  let passengerTransportE = document.getElementsByClassName(
    "passengerTransportEchart"
  );
  for (var i = 0; i < passengerTransportE.length; i++) {
    let myChartPassengerTransport = echarts.init(passengerTransportE[i]);
    option = {
      tooltip: {
        trigger: "axis",
        axisPointer: {
          lineStyle: {
            color: {
              type: "linear",
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              colorStops: [
                {
                  offset: 0,
                  color: "rgba(0, 255, 233,0)",
                },
                {
                  offset: 0.5,
                  color: "rgba(255, 255, 255,1)",
                },
                {
                  offset: 1,
                  color: "rgba(0, 255, 233,0)",
                },
              ],
              global: false,
            },
          },
        },
      },
      grid: [
        {
          top: "8%",
          left: "3%",
          // right: "4%",
          bottom: "5%",
          width: "55%",
          containLabel: true,
        },
        {
          top: "0%",
          right: "4%",
          bottom: "2%",
          width: "50%",
          containLabel: true,
        },
      ],
      xAxis: [
        {
          gridIndex: 0,
          type: "category",
          axisLabel: {
            color: "#A2D4E6",
            fontSize: 12,
            margin: 15,
            interval: 0,
            rotate: 45,
          },
          axisLine: {
            lineStyle: {
              // type: "dashed",
              color: "#657CA8",
              opacity: 0.1,
            },
          },
          axisTick: {
            show: false,
          },
          data: [
            "10-20",
            "10-21",
            "10-22",
            "10-23",
            "10-24",
            "10-25",
            "10-26",
            "10-27",
            "10-28",
            "10-29",
          ],
        },
        {
          gridIndex: 1, //定义index
          show: false,
          type: "value",
        },
      ],

      yAxis: [
        {
          gridIndex: 0,
          type: "value",
          // max: 80, //设置最大值
          min: 0, //最小值
          // max: 140,
          // splitNumber: 4,
          splitLine: {
            lineStyle: {
              // type: "dashed",
              color: "#657CA8",
              opacity: 0.1,
            },
          },
          axisLine: {
            show: false,
          },
          axisLabel: {
            show: true,
            interval: "auto",
            // formatter: "{value}%",
            textStyle: {
              color: "#A2D4E6",
              fontSize: 14,
            },
          },
          axisTick: {
            show: false,
          },
        },
        {
          gridIndex: 1,
          type: "category",
          inverse: true,
          axisLabel: {
            verticalAlign: "top",
            align: "left",
            padding: [10, 15, 10, 15],
            textStyle: {
              color: "#FFFFFF",
              fontSize: "16",
            },
          },
          splitLine: {
            show: false,
          },
          axisTick: {
            show: false,
          },
          axisLine: {
            show: false,
          },
          data: ["1号线", "8号线", "2号线", "10号线", "4号线"],
        },
      ],
      series: [
        {
          xAxisIndex: 0, //使用x轴的index-0，y轴的index-0
          yAxisIndex: 0,
          name: "客运强度",
          type: "line",
          smooth: true,
          symbol: "circle",
          symbolSize: 5,
          lineStyle: {
            normal: {
              color: "#00FFFF",
            },
          },
          // label: {
          //   show: true,
          //   position: "top",
          //   textStyle: {
          //     color: "#00FF72",
          //   },
          // },
          itemStyle: {
            color: "#fff",
            borderColor: "#00FFFF",
            borderWidth: 2,
          },
          areaStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(
                0,
                0,
                0,
                1,
                [
                  {
                    offset: 0,
                    color: "rgba(122,218,229,0.5)",
                  },
                  {
                    offset: 1,
                    color: "rgba(122,218,229,0)",
                  },
                ],
                false
              ),
            },
          },
          data: [
            1.636,
            1.613,
            1.629,
            1.749,
            1.176,
            1.054,
            1.625,
            1.624,
            1.626,
            1.624,
          ],
        },
        {
          xAxisIndex: 1, //使用x轴的index-0，y轴的index-0
          yAxisIndex: 1,
          name: "客运强度",
          type: "bar",
          zlevel: 1,
          itemStyle: {
            normal: {
              barBorderRadius: [0, 5, 5, 0],
              label: {
                show: true, //开启显示
                position: "right", //在上方显示
                color: "#A2D4E6",
              },
              color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
                {
                  offset: 0,
                  color: "#014ADE",
                },
                {
                  offset: 1,
                  color: "#67E0E3",
                },
              ]),
            },
          },
          barWidth: 10,
          data: [3.133, 2.781, 2.441, 2.409, 2.379],
        },
      ],
    };
    // 使用刚指定的配置项和数据显示图表。
    myChartPassengerTransport.setOption(option);
    window.addEventListener("resize", function () {
      myChartPassengerTransport.resize();
    });
  }
}

// 线路平均运距图表
function transportDistanceEchart() {
  let transportDistanceE = document.getElementsByClassName(
    "transportDistanceEchart"
  );
  for (var i = 0; i < transportDistanceE.length; i++) {
    let myChartTransportDistance = echarts.init(transportDistanceE[i]);
    let index = 0;
    var zoomstart = 0;
    var zoomend = 100;
    function restart() {
      option = {
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow",
          },
        },
        legend: {
          show: false,
        },
        grid: {
          top: "2%",
          left: "18%",
          right: "10%",
          bottom: "5%",
        },
        xAxis: {
          type: "value",

          splitLine: {
            show: false,
          },
          axisLabel: {
            show: false,
          },
          axisTick: {
            show: false,
          },
          axisLine: {
            show: false,
          },
        },
        dataZoom: [
          {
            show: false,
            orient: "vertical",
            start: zoomStart(),
            end: zoomEnd(dataListavgline.length),
          },
        ],
        yAxis: {
          type: "category",
          inverse: true,
          axisLine: {
            show: false,
          },
          axisTick: {
            show: false,
          },
          axisPointer: {
            label: {
              show: true,
              margin: 18,
            },
          },
          data: dataListlineID,
          axisLabel: {
            margin: 90,
            fontSize: 12,
            interval: 0,
            align: "left",
            color: "#fff",
            rich: {
              a1: {
                color: "#A2D4E6",
                backgroundColor: {
                  image: "../static/images/one_icon.png",
                },
                width: 30,
                height: 30,
                align: "center",
                // borderRadius: 2,
              },
              a2: {
                color: "#A2D4E6",
                backgroundColor: {
                  image: "../static/images/two_icon.png",
                },
                width: 30,
                height: 30,
                align: "center",
                // borderRadius: 2,
              },
              a3: {
                color: "#A2D4E6",
                backgroundColor: {
                  image: "../static/images/three_icon.png",
                },
                width: 30,
                height: 30,
                align: "center",
                // borderRadius: 2,
              },
              b: {
                color: "#A2D4E6",
                backgroundColor: {
                  image: "../static/images/four_icon.png",
                },
                width: 30,
                height: 30,
                align: "center",
                // borderRadius: 2,
              },
            },
            formatter: function (params) {
              if (index == 8) {
                index = 0;
              }
              index++;
              if (index - 1 < 3) {
                return ["{a" + index + "|" + index + "}" + "  " + params].join(
                  "\n"
                );
              } else {
                return ["{b|" + index + "}" + "  " + params].join("\n");
              }
            },
          },
        },
        series: [
          {
            z: 2,
            name: "value",
            type: "bar",
            barWidth: 12,
            data: dataListavgline.map((item, i) => {
              itemStyle = {
                color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [
                  {
                    offset: 0,
                    color: "#67E0E3",
                  },
                  {
                    offset: 1,
                    color: "#014ADE",
                  },
                ]),
                barBorderRadius: [0, 5, 5, 0],
              };
              return {
                value: item,
                itemStyle: itemStyle,
              };
            }),
            label: {
              show: true,
              position: "right",
              color: "#fff",
              fontSize: 14,
              offset: [10, 0],
            },
          },
        ],
      };
      myChartTransportDistance.setOption(option);
      window.addEventListener("resize", function () {
        myChartTransportDistance.resize();
      });
    }
  }
  restart();
  setInterval(restart, 3000);
  //dataZoom的自动播放
  function zoomStart() {
    if (zoomend >= 100) zoomstart = 0;
    else {
      zoomstart += 7;
    }
    return zoomstart;
  }

  function zoomEnd(length) {
    var displayNum = screen.height > 1080 ? 7 : 7; //根据屏幕分辨率，定默认显示条柱数
    if (length > displayNum && zoomstart === 0) {
      zoomend = (displayNum / length) * 100;
    } else if (length > displayNum) {
      zoomend += 7;
    } else {
      zoomend = 100;
      clearInterval(restart);
    }
    return zoomend;
  }
}

//平均票价
// ticketPriceEchart();
function ticketPriceEchart() {
  let ticketPriceE = document.getElementsByClassName("ticketPriceEchart");
  for (var i = 0; i < ticketPriceE.length; i++) {
    let myChartTicketPrice = echarts.init(ticketPriceE[i]);
    option = {
      tooltip: {
        trigger: "axis",
        axisPointer: {
          lineStyle: {
            color: {
              type: "linear",
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              colorStops: [
                {
                  offset: 0,
                  color: "rgba(0, 255, 233,0)",
                },
                {
                  offset: 0.5,
                  color: "rgba(255, 255, 255,1)",
                },
                {
                  offset: 1,
                  color: "rgba(0, 255, 233,0)",
                },
              ],
              global: false,
            },
          },
        },
      },
      grid: {
        top: "10%",
        left: "5%",
        right: "5%",
        bottom: "5%",
        containLabel: true,
      },
      xAxis: [
        {
          type: "category",
          axisLabel: {
            color: "#A2D4E6",
            fontSize: 14,
            margin: 15,
            //   rotate: 45,
          },
          axisLine: {
            lineStyle: {
              // type: "dashed",
              color: "#657CA8",
              opacity: 0.1,
            },
          },
          axisTick: {
            show: false,
          },
          data: ticketPriceStmtDay,
        },
      ],

      yAxis: [
        {
          type: "value",
          min: 0,
          splitLine: {
            lineStyle: {
              // type: "dashed",
              color: "#657CA8",
              opacity: 0.1,
            },
          },
          axisLine: {
            show: false,
          },
          axisLabel: {
            show: true,
            interval: "auto",
            textStyle: {
              color: "#A2D4E6",
              fontSize: 14,
            },
          },
          axisTick: {
            show: false,
          },
        },
      ],
      series: [
        {
          name: "平均票价",
          type: "line",
          smooth: true,
          symbol: "circle",
          symbolSize: 5,
          lineStyle: {
            normal: {
              color: "#00FFFF",
            },
          },
          // label: {
          //   show: true,
          //   position: "top",
          //   textStyle: {
          //     color: "#00FF72",
          //   },
          // },
          itemStyle: {
            color: "#fff",
            borderColor: "#00FFFF",
            borderWidth: 2,
          },
          areaStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(
                0,
                0,
                0,
                1,
                [
                  {
                    offset: 0,
                    color: "rgba(122,218,229,0.5)",
                  },
                  {
                    offset: 1,
                    color: "rgba(122,218,229,0)",
                  },
                ],
                false
              ),
            },
          },
          data: ticketPriceAvgPrice,
        },
      ],
    };
    // 使用刚指定的配置项和数据显示图表。
    myChartTicketPrice.setOption(option);
    window.addEventListener("resize", function () {
      myChartTicketPrice.resize();
    });
  }
}
// 全员生产率
// productivityEchart();
function productivityEchart() {
  let productivityE = document.getElementsByClassName("productivityEchart");
  for (var i = 0; i < productivityE.length; i++) {
    let myChartproductivity = echarts.init(productivityE[i]);
    option = {
      tooltip: {
        trigger: "axis",
        axisPointer: {
          lineStyle: {
            color: {
              type: "linear",
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              colorStops: [
                {
                  offset: 0,
                  color: "rgba(0, 255, 233,0)",
                },
                {
                  offset: 0.5,
                  color: "rgba(255, 255, 255,1)",
                },
                {
                  offset: 1,
                  color: "rgba(0, 255, 233,0)",
                },
              ],
              global: false,
            },
          },
        },
      },
      grid: {
        top: "8%",
        left: "3%",
        right: "4%",
        bottom: "5%",
        containLabel: true,
      },
      xAxis: [
        {
          type: "category",
          axisLabel: {
            color: "#A2D4E6",
            fontSize: 14,
            margin: 15,
            //   rotate: 45,
          },
          axisLine: {
            lineStyle: {
              // type: "dashed",
              color: "#657CA8",
              opacity: 0.1,
            },
          },
          axisTick: {
            show: false,
          },
          data: productivityStmtDay,
        },
      ],

      yAxis: [
        {
          type: "value",
          // max: 80, //设置最大值
          min: 0, //最小值
          // max: 140,
          // splitNumber: 4,
          splitLine: {
            lineStyle: {
              // type: "dashed",
              color: "#657CA8",
              opacity: 0.1,
            },
          },
          axisLine: {
            show: false,
          },
          axisLabel: {
            show: true,
            interval: "auto",
            formatter: "{value}%",
            textStyle: {
              color: "#A2D4E6",
              fontSize: 14,
            },
          },
          axisTick: {
            show: false,
          },
        },
      ],
      series: [
        {
          name: "全员生产率",
          type: "line",
          showAllSymbol: true,
          symbol: "circle",
          symbolSize: 5,
          lineStyle: {
            normal: {
              color: "#00FF72",
            },
          },
          // label: {
          //   show: true,
          //   position: "top",
          //   textStyle: {
          //     color: "#00FF72",
          //   },
          // },
          itemStyle: {
            color: "#fff",
            borderColor: "#00FF72",
            borderWidth: 2,
          },
          areaStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(
                0,
                0,
                0,
                1,
                [
                  {
                    offset: 0,
                    color: "rgba(0,255,114,0.5)",
                  },
                  {
                    offset: 1,
                    color: "rgba(0,255,114,0)",
                  },
                ],
                false
              ),
            },
          },
          data: productivityPercent,
        },
      ],
    };
    // 使用刚指定的配置项和数据显示图表。
    myChartproductivity.setOption(option);
    window.addEventListener("resize", function () {
      myChartproductivity.resize();
    });
  }
}
//线路客运量
function passengerVolumeEchart() {
  let passengerVolumeE = document.getElementsByClassName(
    "passengerVolumeEchart"
  );
  for (var i = 0; i < passengerVolumeE.length; i++) {
    let myChartPassengerVolume = echarts.init(passengerVolumeE[i]);
    var zoomstart = 0;
    var zoomend = 100;
    function restart() {
      option = {
        tooltip: {
          trigger: "axis",
          axisPointer: {
            lineStyle: {
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: "rgba(0, 255, 233,0)",
                  },
                  {
                    offset: 0.5,
                    color: "rgba(255, 255, 255,1)",
                  },
                  {
                    offset: 1,
                    color: "rgba(0, 255, 233,0)",
                  },
                ],
                global: false,
              },
            },
          },
        },
        grid: {
          top: "15%",
          left: "5%",
          right: "4%",
          bottom: "5%",
          containLabel: true,
        },
        legend: {
          itemGap: 50,
          data: ["日均客运量", "最高日客运量"],
          textStyle: {
            color: "#f9f9f9",
            borderColor: "#fff",
          },
        },
        xAxis: [
          {
            type: "category",
            axisLabel: {
              color: "#A2D4E6",
              fontSize: 14,
              margin: 15,
              //   rotate: 45,
            },
            axisLine: {
              lineStyle: {
                // type: "dashed",
                color: "#657CA8",
                opacity: 0.1,
              },
            },
            axisTick: {
              show: false,
            },
            data: linePassengerVlnNm,
          },
        ],
        dataZoom: [
          {
            type: "slider",
            show: false,
            start: zoomStart(),
            end: zoomEnd(linePassengerVlnNm.length), //默认显示条柱数
          },
        ],
        yAxis: [
          {
            type: "value",
            min: 0,
            // max: 140,
            splitNumber: 7,
            splitLine: {
              lineStyle: {
                // type: "dashed",
                color: "#657CA8",
                opacity: 0.1,
              },
            },
            axisLine: {
              show: false,
            },
            axisLabel: {
              show: true,
              interval: "auto",
              textStyle: {
                color: "#A2D4E6",
                fontSize: 14,
              },
            },
            axisTick: {
              show: false,
            },
          },
        ],
        series: [
          {
            name: "最高日客运量",
            type: "line",
            showAllSymbol: true,
            symbol: "circle",
            symbolSize: 6,
            itemStyle: {
              color: "#00FFFF",
              borderColor: "#00FFFF",
              width: 2,
              shadowColor: "#00FFFF",
              shadowBlur: 2,
            },
            lineStyle: {
              normal: {
                color: "#00FFFF", // 线条颜色
              },
            },
            areaStyle: {
              //区域填充样式
              normal: {
                //线性渐变，前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’，则该四个值是绝对像素位置。
                color: new echarts.graphic.LinearGradient(
                  0,
                  0,
                  0,
                  1,
                  [
                    {
                      offset: 0,
                      color: "rgba(0,255,255,0.5)",
                    },
                    {
                      offset: 1,
                      color: "rgba(0,255,255, 0)",
                    },
                  ],
                  false
                ),
                shadowColor: "rgba(53,142,215, 0.9)", //阴影颜色
                shadowBlur: 20, //shadowBlur设图形阴影的模糊大小。配合shadowColor,shadowOffsetX/Y, 设置图形的阴影效果。
              },
            },
            data: linePassengerVlnHistPasgrNr,
          },
          {
            name: "日均客运量",
            type: "bar",
            barWidth: "20",
            tooltip: {
              show: false,
            },
            label: {
              show: false,
              position: "top",
              textStyle: {
                color: "#0EA0D3",
              },
            },
            itemStyle: {
              normal: {
                barBorderRadius: [4, 4, 0, 0],
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: "#FFDD1F",
                  },
                  {
                    offset: 1,
                    color: "#FF5B1F",
                  },
                ]),
              },
            },
            data: linePassengerVlnDlyPasgrNr,
          },
        ],
      };
      myChartPassengerVolume.setOption(option);
      window.addEventListener("resize", function () {
        myChartPassengerVolume.resize();
      });
    }
    restart();
    setInterval(restart, 3000);
    //dataZoom的自动播放
    function zoomStart() {
      if (zoomend >= 100) zoomstart = 0;
      else {
        zoomstart += 7;
      }
      return zoomstart;
    }

    function zoomEnd(length) {
      var displayNum = screen.width > 1920 ? 12 : 6; //根据屏幕分辨率，定默认显示条柱数
      if (length > displayNum && zoomstart === 0) {
        zoomend = (displayNum / length) * 100;
      } else if (length > displayNum) {
        zoomend += 7;
      } else {
        zoomend = 100;
        clearInterval(restart);
      }
      return zoomend;
    }
  }
}

//高峰小时最小发车间隔
function departureIntervalEchart() {
  let departureIntervalE = document.getElementsByClassName(
    "departureIntervalEchart"
  );
  for (var i = 0; i < departureIntervalE.length; i++) {
    let myChartDepartureInterval = echarts.init(departureIntervalE[i]);
    var zoomstart = 0;
    var zoomend = 100;
    function restart() {
      option = {
        grid: {
          left: "5%",
          right: "5%",
          bottom: "5%",
          top: "13%",
          containLabel: true,
          z: 22,
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            lineStyle: {
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: "rgba(0, 255, 233,0)",
                  },
                  {
                    offset: 0.5,
                    color: "rgba(255, 255, 255,1)",
                  },
                  {
                    offset: 1,
                    color: "rgba(0, 255, 233,0)",
                  },
                ],
                global: false,
              },
            },
          },
        },

        xAxis: [
          {
            type: "category",
            axisLine: {
              lineStyle: {
                color: "#657CA8",
                opacity: 0.1,
              },
            },
            axisLabel: {
              show: true,
              color: "#A2D4E6",
              fontSize: 14,
              interval: 0,
              rotate: lnHrMinDptrIntvl.length > 15 ? 25 : 0, //数据超过15条时，横坐标标签斜置
            },
            axisTick: {
              show: false,
            },
            data: lnNm,
          },
        ],
        dataZoom: [
          {
            type: "slider",
            show: false,
            start: zoomStart(),
            end: zoomEnd(lnHrMinDptrIntvl.length), //默认显示条柱数
          },
        ],
        yAxis: [
          {
            minInterval: 1,
            type: "value",
            name: "单位(秒)",
            nameTextStyle: {
              color: "#A2D4E6",
              fontSize: 14,
            },
            position: "left",
            axisLabel: {
              formatter: "{value}",
            },
            // splitArea: {
            //   show: true,
            // },
            axisLabel: {
              color: "#A2D4E6",
              fontSize: 14,
            },
            splitLine: {
              lineStyle: {
                // type: "dashed",
                color: "#657CA8",
                opacity: 0.1,
              },
            },
            axisLine: {
              show: false,
            },
            axisTick: {
              show: false,
            },
          },
        ],
        series: [
          {
            name: "发车间隔",
            type: "bar",
            barWidth: 20,
            label: {
              show: true, //开启显示
              position: "top", //在上方显示
              formatter: "{c}",
              textStyle: {
                //数值样式
                color: "#fff",
                fontSize: 14,
              },
            },
            // label: {
            //   normal: {
            //     show: true,
            //     position: "top",
            //     color: "#D0D8E2",
            //     formatter: function (params) {
            //       //总数为0时显示数字
            //       if (params.value === 0) {
            //         return params.value;
            //       } else {
            //         return "";
            //       }
            //     },
            //   },
            // },
            data: lnHrMinDptrIntvl,
            itemStyle: {
              normal: {
                barBorderRadius: [4, 4, 0, 0],
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: "#67E0E3",
                  },
                  {
                    offset: 1,
                    color: "#014ADE",
                  },
                ]),
              },
            },
          },
        ],
      };
      myChartDepartureInterval.setOption(option);
      window.addEventListener("resize", function () {
        myChartDepartureInterval.resize();
      });
    }
    restart();
    setInterval(restart, 3000);
    //dataZoom的自动播放
    function zoomStart() {
      if (zoomend >= 100) zoomstart = 0;
      else {
        zoomstart += 7;
      }
      return zoomstart;
    }

    function zoomEnd(length) {
      var displayNum = screen.width > 1920 ? 12 : 6; //根据屏幕分辨率，定默认显示条柱数
      if (length > displayNum && zoomstart === 0) {
        zoomend = (displayNum / length) * 100;
      } else if (length > displayNum) {
        zoomend += 7;
      } else {
        zoomend = 100;
        clearInterval(restart);
      }
      return zoomend;
    }
  }
}
